<template>
	<view style="padding-bottom: 140rpx;">
		<view class="mainpadding topbgc" style="padding-top: 40rpx;">
			<!-- <view class="flexright" @click="jumpurl('/pages/message/message')">
				<view class="bell">
					<view class="shuzi">3</view>
				</view>
			</view> -->
			<!-- 未登錄 -->
			<view class="flexbetween margin_top" style="padding-bottom: 80rpx;" @click="jumpurl('/pages/login/login')"
				v-if="!is_login">
				<view class="flexleft">
					<image src="../../static/image/system/hujiaofw.png" class="headimg margin_right" mode=""></image>
					<view class="titletext bold hei_text">未登錄，點擊登錄</view>
				</view>
				<u-icon name="arrow-right" color="#333" size="16"></u-icon>
			</view>
			<!-- 已登錄 -->
			<view class="flexbetween margin_top" style="padding-bottom: 80rpx;" v-if="is_login">
				<view class="flexleft">
					<image :src="userInfo.logoimage" class="headimg margin_right2" mode=""></image>
					<view>
						<view class="titletext bold hei_text">{{userInfo.name}}</view>
						<view class="hui_text margin_top1">{{userInfo.shopmbl}}</view>
					</view>
				</view>
				<view class="" @click="ewmshow=true">
					<u-icon name="grid" color="#ffb800" size="28"></u-icon>
				</view>
			</view>
			<!-- <view class="flexbetween margin_top" style="padding-bottom: 80rpx;" @click="jumpurl('/pages/my/gerenxx')" v-if="is_login">
				<view class="flexleft">
					<image :src="userInfo.logoimage" class="headimg margin_right2" mode=""></image>
					<view>
						<view class="titletext bold hei_text">{{userInfo.name}}</view>
						<view class="hui_text margin_top1">{{userInfo.shopmbl}}</view>
					</view>
				</view>
				<u-icon name="arrow-right" color="#333" size="16"></u-icon>
			</view> -->
		</view>
		<view class="mainpadding2" style="position: relative; top: -50rpx;">
			<view class="bgc2 mainpadding" v-if="returnRole(1)">
				<view class="flexbetween">
					<view class="main_size bold" style="color: #74580E;">銷售總點數（元）</view>
					<view class="flexright" @click="chakanmx()">
						<view class="main_size bold" style="color: #74580E;">查看明細</view>
						<u-icon name="arrow-right" color="#74580E" size="14"></u-icon>
					</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="hei_text bold" style="font-size: 60rpx;" v-if="!isshow" @click="isshow=!isshow">*****</view>
					<view class="hei_text bold" style="font-size: 60rpx;" v-if="isshow" @click="isshow=!isshow">{{userInfo.countmoney || '0'}}</view>
					<view class="tixian hei_text main_size bold" @click="jumpurl('/pages/workbench/tixian')">提現</view>
				</view>
				<view class="flexbetween mainpadding_top xia ">
					<view class="flexcolumn">
						<view class="xianum">{{userInfo.day_money?userInfo.day_money:0}}</view>
						<view class="xiatext margin_top2">今日營業額</view>
					</view>
					<view class="line"></view>
					<view class="flexcolumn">
						<view class="xianum">{{userInfo.day_order?userInfo.day_order:0}}</view>
						<view class="xiatext margin_top2">今日訂單數</view>
					</view>
					<view class="line"></view>
					<view class="flexcolumn">
						<view class="xianum">{{userInfo.count_order?userInfo.count_order:0}}</view>
						<view class="xiatext margin_top2">歷史訂單數</view>
					</view>
				</view>
			</view>
			<image :src="configImg" @click="shangcheng" class="bannner margin_top" mode=""></image>
			<view class="mainpadding_top ffffff radius">
				<!-- <view class="pdl flexbetween" @click="jumpurl('/pages/my/zuyongpt')">
					<view class="flexleft">
						<image src="../../static/image/system/my1.png" mode="" class="mylefticon margin_right"></image>
						<view class="titletext bold hei_text">租用平臺</view>
					</view>
					<u-icon name="arrow-right" color="#999" size="16"></u-icon>
				</view> -->
				<view class="" style="padding-bottom: 30rpx;" v-if="returnRole(26)">
					<view class="pdl flexbetween"  @click="jumpurl('/pages/workbench/renshugm')">
						<view class="flexleft">
							<image src="../../static/image/system/my2.png" mode="" class="mylefticon margin_right"></image>
							<view class="titletext bold hei_text">購買員工人數</view>
						</view>
						<u-icon name="arrow-right" color="#999" size="16"></u-icon>
					</view>
				</view>
				
				<view class="pdl flexbetween" @click="kefushow=true">
					<view class="flexleft">
						<image src="../../static/image/system/my3.png" mode="" class="mylefticon margin_right"></image>
						<view class="titletext bold hei_text">聯係客服</view>
					</view>
					<u-icon name="arrow-right" color="#999" size="16"></u-icon>
				</view>
				<view class="pdl flexbetween margin_top" v-if="returnRole(27)" @click="show=true;flag=1">
					<view class="flexleft">
						<image src="@/static/image/system/my1.png" mode="" class="mylefticon margin_right"></image>
						<view class="titletext bold hei_text">商品叫號重置</view>
					</view>
					<u-icon name="arrow-right" color="#999" size="16"></u-icon>
				</view>
				<view class="pdl flexbetween margin_top" v-if="returnRole(27)" @click="show=true;flag=2">
					<view class="flexleft">
						<image src="@/static/image/system/my1.png" mode="" class="mylefticon margin_right"></image>
						<view class="titletext bold hei_text">呼叫叫號重置</view>
					</view>
					<u-icon name="arrow-right" color="#999" size="16"></u-icon>
				</view>
				<view class="flexbetween pdl margin_top" @click="jumpurl('/pages/my/shezhi')">
					<view class="flexleft">
						<image src="../../static/image/system/my4.png" mode="" class="mylefticon margin_right"></image>
						<view class="titletext bold hei_text">設置</view>
					</view>
					<u-icon name="arrow-right" color="#999" size="16"></u-icon>
				</view>
				<view class="flexbetween margin_top" @click="jumpurl('/pages/caozuoshouce/shiyongsc?type=2')">
					<view class="flexleft">
						<image src="../../static/image/system/my4.png" mode="" class="mylefticon margin_right"></image>
						<view class="titletext bold hei_text">操作手冊</view>
					</view>
					<u-icon name="arrow-right" color="#999" size="16"></u-icon>
				</view>
			</view>
		</view>
		<u-popup :show="kefushow" @close="kefushow=false" mode="center" :round="10">
			<view class="" style="padding: 40rpx;background-color: #fafafa; min-width: 500rpx; border-radius: 40rpx;">
				<view class="titletext bold hei_text flexcenter">聯係客服</view>
				<view class="flexbetween mainpadding ffffff" style="margin-top: 40rpx;" @click="kfgo()">
					<view class="flexleft">
						<image src="../../static/image/system/my5.png" mode="" class="headimg margin_right"></image>
						<view class="">
							<view class="titletext bold hei_text">Line客服</view>
							<view class="xiaohui">竭誠爲您服務~</view>
						</view>
					</view>
					<u-icon name="arrow-right" color="#999" size="16"></u-icon>
				</view>
				<view class="flexbetween mainpadding ffffff" style="margin-top: 40rpx;" @click="call()">
					<view class="flexleft">
						<image src="../../static/image/system/my6.png" mode="" class="headimg margin_right"></image>
						<view class="">
							<view class="titletext bold hei_text">電話客服</view>
							<view class="xiaohui">{{kf.kf_mobile}}</view>
						</view>
					</view>
					<u-icon name="arrow-right" color="#999" size="16"></u-icon>
				</view>
				<view class="mainpadding">
					<view class="submitbtn" @click="kefushow=false">確定</view>
				</view>
			</view>
		</u-popup>
		<u-popup :show="ewmshow" mode="center" @close="ewmshow = false" round="10">
			<view class="" style="padding-bottom: 50rpx;max-width: 500rpx;">
				<image src="../../static/image/system/ewmtop.png" mode="" class="ewmtop"></image>
				<view class="flexcenter">
					<!-- <image src="../../static/logo.png" class="ewm" mode=""></image> -->
					<uqrcode ref="uqrcode" canvas-id="qrcode" v-bind:value="qrcodeurl" :options="{ margin: 10}"
						size="150">
					</uqrcode>
				</view>
				<view class="main_size flexcenter bold hei_text mainpadding">{{userInfo.name}}</view>
				<view class="xiaolv main_size flexcenter" style="font-weight: bold;">商家二維碼</view>
			</view>
		</u-popup>
		<u-modal :show="show" showCancelButton confirmColor="#FFB800" @cancel="show=false" @confirm="resetjh()" confirmText="確認" cancelText="取消">
			<view class="slot-content color_ling text_weight text">
				您確定要重置{{flag==1?"商品":"呼叫"}}排號嗎？
			</view>
		</u-modal>
		<tabbar ref="tabbarref" :current="3"></tabbar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				kefushow: false,
				userInfo: {},
				ewmshow: false,
				qrcodeurl: "",
				kf: {},
				isshow:false,
				is_shop:false,//is_shop是否为商家  1 不是   2是
				authority:[],
				show:false,
				flag:1,//1商品，2呼叫
				configImg:""
			}
		},
		onLoad() {
			uni.hideTabBar()
			this.getewm()
			this.gettxt()
			this.getconfigimg()
		},
		onShow() {
			this.$nextTick(() => {
				this.$refs.tabbarref.init()
			});
			this.is_login = this.http.checkIsLogin();
			if (this.is_login) {
				this.getUserInfo()
				
			} else {
				this.userInfo = null
			}
		},
		methods: {
			async resetjh(){
				this.show = false
				let data = {
					shop_id: uni.getStorageSync("shop_id"),
					is_resetcall:1
				}
				if(this.flag==2){//呼叫叫號重置
					data = {
						shop_id: uni.getStorageSync("shop_id"),
						is_resetcall1:1
					}
				}
				let res = await this.http.request("/api/shop/Shopedit", "POST",data)
				if (res.code == 1) {
					this.http.toast("重置成功");
				}else{
					this.http.toast(res.msg);
				}
			},
			returnRole(val){
				if(this.is_shop==2){
					return true
				}
				let flag =  this.authority.some((item)=>{
					return item == val
				})
				return flag
			},
			call() {
				uni.makePhoneCall({
					phoneNumber: this.kf.kf_mobile //仅为示例
				});
			},
			shangcheng(){
				location.href = this.kf.shop_url;
				// uni.navigateTo({
				// 	url:"/pages/system/webview?url" + this.kf.shop_url
				// 	// url:"pag" + this.kf.shop_url
				// })
			},
			kfgo() {
				console.log(this.kf.kf_link)
				location.href = this.kf.kf_link;
			},
			getconfigimg(){
				this.http.request("/api/index/getConfigInfoItem", "GET", {
					pidtype: "otherset",
					type:"shop_mine_image"
				}).then(res=>{
					this.configImg = res.data
				})
			},
			gettxt() {
				this.http.request("/api/index/getText", "GET", {
					type: 3
				}).then(res=>{
					this.kf = res.data
				})
			},
			getewm() {
				this.http.request("/api/index/getshop_url", "GET", {}).then(res=>{
					this.qrcodeurl = res.data + "?id=" + uni.getStorageSync("shop_id")+"&issm=1"
				})
			},
			getUserInfo() { //获取店鋪信息
				this.http.request('/api/shop/Shopdeail', 'POST', {
					shop_id: uni.getStorageSync("shop_id"),
				}).then(res=>{
					if (res.code == 1) {
						uni.setStorageSync("appkey", res.data.appkey)
						uni.setStorageSync("hy_type", res.data.hy_type)
						uni.setStorageSync("opentable_status", res.data.opentable_status)
						uni.setStorageSync("is_sdkfp", res.data.is_sdkfp)
						uni.setStorageSync("is_call_sdkfp", res.data.is_call_sdkfp)
						uni.setStorageSync("is_pos_sdkfp", res.data.is_pos_sdkfp)
						uni.setStorageSync("houtel_type",res.data.houtel_type)
						res.data.logoimage = this.imgUrlUser + res.data.logoimage
						this.is_shop = res.data.is_shop
						this.authority = res.data.shopstaff?res.data.shopstaff.authority.split(","):[]
						this.userInfo = res.data
					} else{
						this.http.toast(res.msg)
					}
				})
				
			},
			jumpview() {
				uni.navigateTo({
					url: "/pages/system/webview?url=" + "https://lin.ee/hy1mD6W"
				})
			},
			chakanmx(){
				uni.navigateTo({
					url:"/pages/workbench/chakanmx"
				})
			},
			jumpurl(url) {
				uni.navigateTo({
					url
				})
			}
		}
	}
</script>

<style>
	.ewm {
		margin-top: 50rpx;
		width: 300rpx;
		height: 300rpx;
	}

	.ewmtop {
		width: 500rpx;
		height: 180rpx;
	}

	.mylefticon {
		width: 38rpx;
		height: 38rpx;
	}

	.bannner {
		width: 100%;
		height: 150rpx;
	}

	.topbgc {
		background: linear-gradient(180deg, #FAF6E8 0%, #FAF8F2 80%, #fafafa 99%);
	}

	.headimg {
		width: 100rpx;
		height: 100rpx;
		min-width: 100rpx;
	}

	.bell {
		width: 43rpx;
		height: 43rpx;
		background-image: url("../../static/image/system/bell.png");
		background-size: 100% 100%;
		position: relative;
	}

	.shuzi {
		position: absolute;
		right: -13rpx;
		top: -15rpx;
		color: #fff;
		width: 30rpx;
		height: 30rpx;
		border-radius: 50rpx;
		background-color: #ff0000;
		font-size: 12rpx;
		text-align: center;
		line-height: 30rpx;
	}
	.bgc2{
		background-image: url('@/static/image/system/workbenckbgc2.png');
		background-size: 100% 100%;
		border-radius: 20rpx;
	}
	.tixian{
		padding: 10rpx 40rpx;
		background-color: #fff7e2;
		border-radius: 50rpx;
	}
	.xia{
		border: 1rpx solid rgb(255, 255, 255);
		border-radius: 20rpx;
	}
	.xianum{
		font-size: 30rpx;
		font-family: DIN-Bold, DIN;
		font-weight: bold;
		color: #360405;
	}
	.xiatext{
		font-size: 26rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #7A540B;
	}
	.line{
		width: 1rpx;
		background: rgba(255, 255, 255,.3);
		height: 50rpx;
	}
</style>